package lab9.com.acme.bankapp.domain.bank;


public class CheckingAccount extends AbstractAccount
{
	public static final String NOT_ENOUGH_CHECKING = "There is not enough money on your checking account";
	private double overdraft;
	
	public CheckingAccount(final double amount, 
			final double overdraftSize)
	{
		super(amount);
		overdraft = overdraftSize;
	}

	@Override
	public void deposit(double amount)
	{
		this.balance += amount; 
	}
	
	@Override
	public void withdraw(double amount)
	{
		if (amount < this.balance)
		{
			this.balance -= amount;
		}
		else if (amount < this.balance + overdraft)
		{
			overdraft -= (amount - this.balance);
			this.balance = 0D;
		}
		else
		{
			System.out.println(NOT_ENOUGH_CHECKING);
		}
	}
	
	@Override
	public double maximumAmountToWithdraw()
	{
		return balance + overdraft;
	}
}
